#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive


${HIVE_HOME} -S -e "
INSERT INTO edu_online_dwb.dwb_visit_consult_detail
SELECT
    a.id AS id,
    substr(create_time,1,10) AS day,
    substr(create_time,1,7) AS month,
    quarter(create_time) AS quarter,
    substr(create_time,1,4) AS year,
    session_id,
    sid,
    if(seo_source = '',null,seo_source) AS seo_source,
    ip,
    area,
    country,
    province,
    if(city='',null,city) AS city,
    origin_channel,
    msg_count,
    from_url
FROM edu_online_dwd.fact_web_chat_ems_2019_07 a
LEFT JOIN edu_online_dwd.fact_web_chat_text_ems_2019_07 b
ON a.id = b.id;
"